import React from 'react'
import EventEmitter from '../events'
import store from '../store'
export default class Teacher extends React.Component {
    constructor(){
        super();
        this.state={
            msg:'老师'
        }
        console.log(store,store.getState(),'store')
    }
    componentDidMount(){
        EventEmitter.addListener('changeMsg',(msg)=>{
             this.setState({
                 msg
             })
        })
    }
    shouldComponentUpdate(nextProps,nextState){
        console.log('前',nextProps,'后',this.props,Object.is(nextProps,this.props))
        if(nextProps.msg!==this.props.msg){
            return true;
        }else{
           return false       
        }
    }
    render() {
        console.log('teacher')
    return <div>{this.state.msg}
    </div>
    }
}